/*
 * This source code is part of TWaver 4.0
 *
 * Serva Software PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * Copyright 2002 - 2011 Serva Software. All rights reserved.
 */

package demo.network.miscellaneous.instrument.element;

import demo.network.miscellaneous.instrument.elementui.ThermometerUI;
import twaver.*;
import twaver.Node;

public class Thermometer extends Node {

    private int percentage = 0;

    public Thermometer() {
        super();
        this.init();
    }

    public Thermometer(Object id) {
        super(id);
        this.init();
    }

    private void init(){
    	this.setPercentage(60);
    }
    
    public String getUIClassID() {
        return ThermometerUI.class.getName();
    }

    public int getPercentage() {
        return percentage;
    }

    public void setPercentage(int percentage) {
        percentage = percentage < 0 ? 0 : percentage;
        percentage = percentage > 100 ? 100 : percentage;
        int oldValue = this.percentage;
        this.percentage = percentage;
        this.firePropertyChange("percentage", oldValue, percentage);
    }

    protected void exportValues(Element element, TDataBox box) {
        super.exportValues(element, box);
        if (element != null && element instanceof Thermometer) {
            Thermometer Thermometer = (Thermometer) element;
            Thermometer.setPercentage(this.getPercentage());
        }
    }

}